package edu.snake.implement.model.character.listenerDecorator;


import edu.snake.core.model.character.Character;
import edu.snake.implement.utils.PairCharacter;

import java.awt.event.ActionEvent;

public class CharacterListenerImplSnake extends CharacterListenerAdapterBaseImpl {


    public CharacterListenerImplSnake(Character character) {
        super(character);
    }

    @Override
    public Character move() {
        Character character = super.move();
        if (character == null) {
            fireActionPerformed(new ActionEvent(this.character, 0, "moved",
                    System.currentTimeMillis(),
                    0));
        } else {
            fireActionPerformed(new ActionEvent(new PairCharacter(this, character), 0, "collision",
                    System.currentTimeMillis(),
                    0));
        }
        return character;
    }
}
